package service

import (
	"project-im/config"
	"project-im/internal/model/dao"
)

func FriendDelete(userId int, friendId int) string {
	tx := config.DB.Begin()
	err := tx.Model(&dao.ImFriend{}).Where("user_id=? && friend_id=?", userId, friendId).Delete(&dao.ImFriend{}).Error
	if err != nil {
		tx.Rollback()
		return "好友删除失败"
	}
	err = config.DB.Model(&dao.ImFriend{}).Where("user_id=? && friend_id=?", friendId, userId).Delete(&dao.ImFriend{}).Error
	if err != nil {
		tx.Rollback()
		return "好友删除失败"
	}
	tx.Commit()
	return ""
}
